<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <title>ATSaddnz</title>
    <link rel="stylesheet" type="text/css" href="csound.css" />
    <meta name="generator" content="DocBook XSL Stylesheets V1.78.1" />
    <link rel="home" href="index.html" title="The Canonical Csound Reference Manual" />
    <link rel="up" href="OpcodesTop.html" title="Orchestra Opcodes and Operators" />
    <link rel="prev" href="ATSadd.html" title="ATSadd" />
    <link rel="next" href="ATSbufread.html" title="ATSbufread" />
  </head>
  <body>
    <div class="navheader">
      <table width="100%" summary="Navigation header">
        <tr>
          <th colspan="3" align="center">ATSaddnz</th>
        </tr>
        <tr>
          <td width="20%" align="left"><a accesskey="p" href="ATSadd.html">Prev</a> </td>
          <th width="60%" align="center">Orchestra Opcodes and Operators</th>
          <td width="20%" align="right"> <a accesskey="n" href="ATSbufread.html">Next</a></td>
        </tr>
      </table>
      <hr />
    </div>
    <div class="refentry">
      <a id="ATSaddnz"></a>
      <div class="titlepage"></div>
      <a id="IndexATSaddnz" class="indexterm"></a>
      <div class="refnamediv">
        <h2>
          <span class="refentrytitle">ATSaddnz</span>
        </h2>
        <p>ATSaddnz —  uses the data from an ATS analysis file to perform noise resynthesis.
        </p>
      </div>
      <div class="refsect1">
        <a id="idp90396352"></a>
        <h2>Description</h2>
        <p>
            <span class="emphasis"><em>ATSaddnz</em></span> reads from an ATS analysis file and uses the data to perform additive synthesis using a modified randi function.
        </p>
      </div>
      <div class="refsect1">
        <a id="idp90398032"></a>
        <h2>Syntax</h2>
        <pre class="synopsis">ar <span class="command"><strong>ATSaddnz</strong></span> ktimepnt, iatsfile, ibands[, ibandoffset, ibandincr]</pre>
      </div>
      <div class="refsect1">
        <a id="idp90400240"></a>
        <h2>Initialization</h2>
        <p>
            <span class="emphasis"><em>iatsfile</em></span> – the ATS number (n in ats.n) or the name in quotes of the analysis file made using <a class="ulink" href="http://www-ccrma.stanford.edu/~juan/ATS.html" target="_top"><em class="citetitle">ATS</em></a>.
        </p>
        <p><span class="emphasis"><em>ibands</em></span> – number of noise bands that will be used in the resynthesis (the noise has a maximum of 25 bands)
        </p>
        <p><span class="emphasis"><em>ibandoffset</em></span> (optional) – is the first noise band used (defaults to 0).
        </p>
        <p><span class="emphasis"><em>ibandincr</em></span> (optional) – sets an increment by which these synthesis opcodes counts up from <span class="emphasis"><em>ibandoffset</em></span> for ibins components in the re-synthesis (defaults to 1).
        </p>
      </div>
      <div class="refsect1">
        <a id="idp90405888"></a>
        <h2>Performance</h2>
        <p><span class="emphasis"><em>ktimepnt</em></span> – The time pointer in seconds used to index the ATS file. Used for <span class="emphasis"><em>ATSaddnz</em></span> exactly the same as for <a class="link" href="pvoc.html" title="pvoc"><em class="citetitle">pvoc</em></a> and <a class="link" href="ATSadd.html" title="ATSadd"><em class="citetitle">ATSadd</em></a>.</p>
        <p><span class="emphasis"><em>ATSaddnz</em></span> and <a class="link" href="ATSadd.html" title="ATSadd"><em class="citetitle">ATSadd</em></a> are based on <a class="link" href="pvadd.html" title="pvadd"><em class="citetitle">pvadd</em></a> by Richard Karpen and use files created by Juan Pampin's ATS (<a class="ulink" href="http://www-ccrma.stanford.edu/~juan/ATS.html" target="_top"><em class="citetitle">Analysis - Transformation - Synthesis</em></a>).
        </p>
        <p><span class="emphasis"><em>ATSaddnz</em></span> also reads from an ATS file but it resynthesizes the noise from noise energy data contained in the ATS file. It uses a modified randi function to create band limited noise and modulates that with a cosine wave, to synthesize a user specified selection of frequency bands. Modulating the noise is required to put the band limited noise in the correct place in the frequency spectrum.
        </p>
      </div>
      <div class="refsect1">
        <a id="idp90414528"></a>
        <h2>Examples</h2>
        <pre class="programlisting">  ktime <span class="opc">line</span>     0, p3, 2.5
  asig  <span class="opc">ATSaddnz</span> ktime, "clarinet.ats", 25
        </pre>
        <p>In the example above we're synthesizing all 25 noise bands from the data contained in the ATS analysis file called "clarinet.ats".
        </p>
      </div>
      <div class="refsect1">
        <a id="idp90418016"></a>
        <h2>Examples</h2>
        <p>
      Here is a complete example of the ATSaddnz opcode. It uses the file <a class="ulink" href="examples/ATSaddnz.csd" target="_top"><em class="citetitle">ATSaddnz.csd</em></a>.

      </p>
        <div class="example">
          <a id="idp90419888"></a>
          <p class="title">
            <strong>Example 61. Example of the ATSaddnz opcode.</strong>
          </p>
          <div class="example-contents">
            <pre class="programlisting">
<span class="csdtag">&lt;CsoundSynthesizer&gt;</span>
<span class="csdtag">&lt;CsOptions&gt;</span>
<span class="comment">; Select audio/midi flags here according to platform</span>
-odac     <span class="comment">;;;RT audio out</span>
<span class="comment">;-iadc    ;;;uncomment -iadc for RT audio input is needed too</span>
<span class="comment">; For Non-realtime ouput leave only the line below:</span>
<span class="comment">; -o ATSaddnzwav -W ;;; for file output any platform</span>
<span class="csdtag">&lt;/CsOptions&gt;</span>
<span class="csdtag">&lt;CsInstruments&gt;</span>

<span class="ohdr">sr</span> <span class="op">=</span> 44100
<span class="ohdr">ksmps</span> <span class="op">=</span> 32
<span class="ohdr">nchnls</span> <span class="op">=</span> 2
<span class="ohdr">0dbfs</span> <span class="op">=</span> 1

<span class="oblock">instr</span> 1	<span class="comment">; "beats.ats" is created by atsa</span>

ktime	<span class="opc">line</span>     0, p3, 2
asig	<span class="opc">ATSaddnz</span> ktime, "beats.ats", 1, 24
	<span class="opc">outs</span>	asig<span class="op">*</span>10, asig<span class="op">*</span>10	<span class="comment">;amplify</span>
<span class="oblock">endin</span>

<span class="csdtag">&lt;/CsInstruments&gt;</span>
<span class="csdtag">&lt;CsScore&gt;</span>

<span class="stamnt">i</span> 1 0 2 
<span class="stamnt">e</span>

<span class="csdtag">&lt;/CsScore&gt;</span>
<span class="csdtag">&lt;/CsoundSynthesizer&gt;</span>
</pre>
          </div>
        </div>
        <p><br class="example-break" />
    </p>
        <p>Here we synthesize only the 25th noise band (<span class="emphasis"><em>ibandoffset</em></span> of 24 and <span class="emphasis"><em>ibands</em></span> of 1).
        </p>
        <p>
      Here is another example of the ATSaddnz opcode. It uses the file <a class="ulink" href="examples/ATSaddnz-2.csd" target="_top"><em class="citetitle">ATSaddnz-2.csd</em></a>.
      </p>
        <div class="example">
          <a id="idp90424208"></a>
          <p class="title">
            <strong>Example 62. Example 2 of the ATSaddnz opcode.</strong>
          </p>
          <div class="example-contents">
            <pre class="programlisting">
<span class="csdtag">&lt;CsoundSynthesizer&gt;</span>
<span class="csdtag">&lt;CsOptions&gt;</span>
-odac -d -m1
<span class="csdtag">&lt;/CsOptions&gt;</span>
<span class="csdtag">&lt;CsInstruments&gt;</span>
<span class="comment">;example by joachim heintz</span>
<span class="ohdr">sr</span> <span class="op">=</span> 44100
<span class="ohdr">ksmps</span> <span class="op">=</span> 32
<span class="ohdr">nchnls</span> <span class="op">=</span> 2
<span class="ohdr">0dbfs</span> <span class="op">=</span> 1

<span class="oblock">instr</span> AllTheNoise
Sfile    <span class="op">=</span>        "fox.ats"
         <span class="opc">prints</span>   "Resynthesizing with all the noise.\n"
iDur     <span class="opc">ATSinfo</span>  Sfile, 7
p3       <span class="op">=</span>        iDur
ktime    <span class="opc">line</span>     0, iDur, iDur
asig     <span class="opc">ATSaddnz</span> ktime, Sfile, 25
         <span class="opc">outs</span>     asig, asig

<span class="comment">;start next instr</span>
         <span class="opc">event_i</span>  "i", "NoiseInBandsOfFive", iDur<span class="op">+</span>1, 1, 0
<span class="oblock">endin</span>

<span class="oblock">instr</span> NoiseInBandsOfFive
Sfile    <span class="op">=</span>        "fox.ats"
         <span class="opc">prints</span>   "Resynthesizing with <span class="opc">noise</span> bands <span class="op">%</span>d <span class="op">-</span> <span class="op">%</span>d.\n", p4, p4<span class="op">+</span>5
iDur     <span class="opc">ATSinfo</span>  Sfile, 7
p3       <span class="op">=</span>        iDur
ktime    <span class="opc">line</span>     0, iDur, iDur
asig     <span class="opc">ATSaddnz</span> ktime, Sfile, 5, p4
         <span class="opc">outs</span>     asig, asig

<span class="comment">;start next instr</span>
<span class="octrl">if</span> p4 <span class="op">&lt;</span> 20 then
         <span class="opc">event_i</span>  "i", "NoiseInBandsOfFive", iDur<span class="op">+</span>1, 1, p4<span class="op">+</span>5
<span class="octrl">endif</span>
<span class="oblock">endin</span>
<span class="csdtag">&lt;/CsInstruments&gt;</span>
<span class="csdtag">&lt;CsScore&gt;</span>
<span class="stamnt">i</span> "AllTheNo<span class="stamnt">i</span>se" 0 1
<span class="stamnt">e</span> 25
<span class="csdtag">&lt;/CsScore&gt;</span>
<span class="csdtag">&lt;/CsoundSynthesizer&gt;</span>
</pre>
          </div>
        </div>
        <p><br class="example-break" />
    </p>
      </div>
      <div class="refsect1">
        <a id="idp90426224"></a>
        <h2>See also</h2>
        <p><a class="link" href="ATSread.html" title="ATSread"><em class="citetitle">ATSread</em></a>, 
            <a class="link" href="ATSreadnz.html" title="ATSreadnz"><em class="citetitle">ATSreadnz</em></a>, 
            <a class="link" href="ATSinfo.html" title="ATSinfo"><em class="citetitle">ATSinfo</em></a>, 
            <a class="link" href="ATSbufread.html" title="ATSbufread"><em class="citetitle">ATSbufread</em></a>, 
            <a class="link" href="ATScross.html" title="ATScross"><em class="citetitle">ATScross</em></a>, 
            <a class="link" href="ATSinterpread.html" title="ATSinterpread"><em class="citetitle">ATSinterpread</em></a>, 
            <a class="link" href="ATSpartialtap.html" title="ATSpartialtap"><em class="citetitle">ATSpartialtap</em></a>, 
            <a class="link" href="ATSaddnz.html" title="ATSaddnz"><em class="citetitle">ATSaddnz</em></a>, 
            <a class="link" href="ATSsinnoi.html" title="ATSsinnoi"><em class="citetitle">ATSsinnoi</em></a></p>
      </div>
      <div class="refsect1">
        <a id="idp90435696"></a>
        <h2>Credits</h2>
        <p>
            </p>
        <table border="0" summary="Simple list" class="simplelist">
          <tr>
            <td>Author: Alex Norman</td>
          </tr>
          <tr>
            <td>Seattle,Washington</td>
          </tr>
          <tr>
            <td>2004</td>
          </tr>
        </table>
        <p>
        </p>
      </div>
    </div>
    <div class="navfooter">
      <hr />
      <table width="100%" summary="Navigation footer">
        <tr>
          <td width="40%" align="left"><a accesskey="p" href="ATSadd.html">Prev</a> </td>
          <td width="20%" align="center">
            <a accesskey="u" href="OpcodesTop.html">Up</a>
          </td>
          <td width="40%" align="right"> <a accesskey="n" href="ATSbufread.html">Next</a></td>
        </tr>
        <tr>
          <td width="40%" align="left" valign="top">ATSadd </td>
          <td width="20%" align="center">
            <a accesskey="h" href="index.html">Home</a>
          </td>
          <td width="40%" align="right" valign="top"> ATSbufread</td>
        </tr>
      </table>
    </div>
  </body>
</html>
